# 使用 Ubuntu 基础镜像
FROM python:3.8

# 设置工作目录
WORKDIR /app

# 复制应用文件
COPY ./app /app

# 添加阿里云源
RUN echo "deb http://mirrors.aliyun.com/debian/ buster main non-free contrib\n\
deb-src http://mirrors.aliyun.com/debian/ buster main non-free contrib\n\
deb http://mirrors.aliyun.com/debian-security buster/updates main\n\
deb-src http://mirrors.aliyun.com/debian-security buster/updates main\n\
deb http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib\n\
deb-src http://mirrors.aliyun.com/debian/ buster-updates main non-free contrib\n\
deb http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib\n\
deb-src http://mirrors.aliyun.com/debian/ buster-backports main non-free contrib" > /etc/apt/sources.list


# 更新包索引并安装依赖
RUN apt-get update -y --fix-missing && apt-get install -y \
    gcc \
    g++ \
    make \
    cmake \
    libffi-dev \
    libssl-dev \
    tzdata
# 设置时区
ENV TIME_ZONE Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime && echo $TIME_ZONE > /etc/timezone

# 升级 pip 并使用清华源安装 Python 依赖
RUN pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install fastapi -i https://pypi.tuna.tsinghua.edu.cn/simple
RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

# 赋予启动脚本执行权限
RUN chmod 777 /app/start.sh

# 容器启动时执行的命令
CMD ["python", "main.py"]
